;
$(function () {
    $('.menu .nav').on('click', 'li:not(.nav-parent) > a', function () {
        var $this = $(this);
        $('.menu .nav .active').removeClass('active');
        $this.closest('li').addClass('active');
        $this.closest('.nav-parent').addClass('active');
        var _url = $(this).attr('url_val');
        var obj = {url:_url,title:$.trim($(this).text())};
        changeIframeSrc(obj);
    });
    $('.notice-li').popover({
        template: '<div class="popover"><h3 class="popover-title"></h3><div class="popover-content"></div></div>',
        html: 'true',
        placement: 'bottom',
        tipClass: 'popover-fixed',
        trigger: 'manual',//手动隐藏和显示
        content: getNoticesHtml()
    }).on('focus', function () {
        $(this).popover('show');
    }).on('blur', function () {
        $(this).popover('hide');
    });
    $(".bread li").eq(0).click(function () {
        $(".bread li").eq(1).css('display', 'none');
    });

});

function getNoticesHtml() {
    return '<div class="popover-content">' +
        '<div class="list list-condensed">\n' +
        '  <div class="items items-hover">\n' +
        '    \n' +
        '    <div class="item">\n' +
        '      <div class="item-content">\n' +
        '        <div class="text">四姑娘山旅游系统延期 <span style="color:red">1.5</span> 天</div>\n' +
        '      </div>\n' +
        '    </div>\n' +
        '    <div class="item">\n' +
        '      <div class="item-content">\n' +
        '        <div class="text">三亚旅游系统延期 <span style="color:red">3</span> 天</div>\n' +
        '      </div>\n' +
        '    </div>\n' +
        '\t<div class="item">\n' +
        '      <div class="item-content">\n' +
        '        <div class="text">西藏旅游系统延期 <span style="color:red">6</span> 天</div>\n' +
        '      </div>\n' +
        '    </div>\n' +
        '  </div>\n' +
        ' \n' +
        '</div>' +
        '</div>';
}

/**
 * @description：控制iframe内容显示及操作路径，若是多路径数组要按照路径的先后顺序插值
 * @author: pmq
 * @time: 2017/6/26 18:24
 * @param:obj: {url:'',title:''}||[{url:'',title:''}]
 */
function changeIframeSrc(obj) {
    //备份之前的路径
    var _last_r = $(".bread li").eq(0).siblings();
    //删除之前的路径
    $(".bread li").eq(0).siblings().remove();
    var _r = '';
    var _url = basePath;
    if($.isArray(obj)){//多级路径，数组要按照路径的先后顺序插值
        for(var i=0; i<obj.length; i++){
            if(i == (obj.length-1)){
                _r += '<li>'+obj[i].title+'</li>';
                _url += obj[i].url;
            }else{
                _r += '<li><a href="javascript:;" url_val=\"'+obj[i].url+'\" onclick=\"bread_onClick(this)\">'+obj[i].title+'</a></li>';
            }
        }
    }else{
        _r += '<li>'+obj.title+'</li>';
        _url += obj.url;
    }
    $(".bread").append(_r);
    _url += (_url.indexOf('?')>-1?'&t=':'?t=')+new Date().getTime();//防止缓存
    document.getElementById("content_iframe").src = _url;
}
function bread_onClick(dom) {
    changeIframeSrc({url:$(dom).attr("url_val"),title:$(dom).text()});
}
function getIframeFullScreen() {
    $('.nav-top').css("display", 'none');
    $('.left-menu').css("display", 'none');
    $('.bread-div').css("display", 'none');
    var _h = $(document).height();
    var _w = $(document).width();
    $('.content-right').css('top', 0);
    $('.content-right').css('left', 0);
    $('.content-right').width(_w).height(_h);
}

function cancelIframeFullScreen() {
    $('.nav-top').css("display", 'block');
    $('.left-menu').css("display", 'block');
    $('.bread-div').css("display", 'block');
    var _h = $(document).height();
    var _w = $(document).width();
    $('.content-right').width(_w - 200).height(_h - 78);
    $('.content-right').css('top', 78);
    $('.content-right').css('left', 200);
}
